package com.example.business_oa.service;

import cn.hutool.core.date.DateUtil;
import com.example.comment_oa.dubbo.AmountDubbo;
import com.example.comment_oa.pojos.Amount;
import com.example.comment_oa.pojos.Budget;
import com.example.comment_oa.pojos.Standard;
import com.example.comment_oa.pojos_vo.FybxVo;
import io.seata.spring.annotation.GlobalTransactional;
import lombok.Data;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
@Service
public class FybxService {
    @DubboReference(version = "1.0.0")
    AmountDubbo amountDubbo;

    //查询差旅报销标准
    @GlobalTransactional(timeoutMills = 300000)
    public List<Standard> selectStand(String budgetKm){
        return amountDubbo.selectStandard(budgetKm);
    }


    //根据年月，部门，预算科目查询预算
    @GlobalTransactional(timeoutMills = 300000)
    public List<Budget>  selectByyscs(String year, String month, String deptName, String budgetKm){
        return amountDubbo.selectByyscs(year,month,deptName,budgetKm);
    }

    //新增报销主表
    @GlobalTransactional(timeoutMills = 300000)
    public int insertBXzb(String amountProcess, String amountTitle, Date amountTime,String deptName,Integer empId,Integer amountState,Double amountMoney,String empCard,String empName){
        return amountDubbo.insertBXzb(amountProcess,amountTitle,amountTime,deptName,empId,amountState,amountMoney,empCard,empName);
    }



    //新增报销详表
    @GlobalTransactional(timeoutMills = 300000)
    public int insertBxxb(String bxkm, Double bxje, String invoicePhone, String amountProcess, String deptName, Date cdqj){
        return amountDubbo.insertBxxb(bxkm,bxje,invoicePhone,amountProcess,deptName,cdqj);
    }

    //根据发票号码修改发票状态
    @GlobalTransactional(timeoutMills = 300000)
    public  int updateinvoicePhone(String invoicePhone){
        return amountDubbo.updateinvoicePhone(invoicePhone);
    }

    //修改预算初始额
    @GlobalTransactional(timeoutMills = 300000)
    public int updateCsys(Double budgetCsmoney, String budgetYear, String budgetMonth,String deptName, String budgetKm){
        return amountDubbo.updateCsys(budgetCsmoney,budgetYear,budgetMonth,deptName, budgetKm);
    }

    //修改发票状态为已报销
    @GlobalTransactional(timeoutMills = 300000)
    public int updatefazt(String invoicePhone){
        return amountDubbo.updatestate(invoicePhone);
    }


    //修改报销状态
    @GlobalTransactional(timeoutMills = 300000)
    public int updatebxState(Integer amountState,String amountProcess){
        return amountDubbo.updatebxstate(amountState,amountProcess);
    }

    //增加初始预算
    @GlobalTransactional(timeoutMills = 300000)
    public int csyszj(Double budgetCsmoney, String budgetYear, String budgetMonth,String deptName, String budgetKm){
        return amountDubbo.updateCs(budgetCsmoney,budgetYear,budgetMonth,deptName,budgetKm);
    }


    //减少剩余预算
    @GlobalTransactional(timeoutMills = 300000)
    public int updateSy(Double budgeSymoney, String budgetYear, String budgetMonth,String deptName, String budgetKm){
        return amountDubbo.updateSy(budgeSymoney,budgetYear,budgetMonth,deptName,budgetKm);
    }


    //查询审批数据
    @GlobalTransactional(timeoutMills = 300000)
    public List<Amount> spsj(String amountProcess){
        return amountDubbo.spju(amountProcess);
    }



}
